<?php

namespace app\admin\model;

use app\admin\model\CommonModel;

class ShopGoodsModel extends CommonModel
{
    const IS_HOT   = ['否', '是'];//是否热门
    const IS_SHELF = ['否', '是'];//是否上架
    protected $autoWriteTimestamp = true;//自动写入时间戳
    protected $pk = 'id';//主键，可以用get查询

    //规格等级最多三级，一级，二级，三级
    const LEVEL_FIRST  = 0;
    const LEVEL_SECOND = 1;
    const LEVEL_THIRD  = 2;

    //规格层级
    const FIRST  = 1;
    const SECOND = 2;
    const THIRD  = 3;

    //是否有规格组
    const SPECS_NO  = 0;//无
    const SPECS_YES = 1;//有

    public function shopRelationMany()
    {
        return $this->hasMany('shopGoodsRelationModel', 'shop_goods_id', 'id')->field('id,shop_goods_id,specs_attr,stock,goods_coin');
    }
}
